package com.fingersoft.im.transfer

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import com.fingersoft.business.BusinessContext

/**
 * @author：mac  Email：jooperge@163.com
 * 描述：
 * 修改历史:
 * <p>
 * 创建于： 2020/8/13
 */
class TransferActivity : Activity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        intent?.let {
            parseIntent(it)
        }
    }

    override fun onNewIntent(intent: Intent?) {
        super.onNewIntent(intent)
        intent?.let {
            parseIntent(it)
        }
    }

    override fun onPause() {
        super.onPause()
        finish()
    }

    private fun parseIntent(intent: Intent) {
        var url: String? = null
        var title: String? = null
        intent.extras?.containsKey("url").takeIf { it == true }?.let {
            url = intent.extras?.getString("url")
        }
        intent.extras?.containsKey("title").takeIf { it == true }?.let {
            title = intent.extras?.getString("title")
        }
        BusinessContext.webViev?.openApp(application, url, title, "notification")
    }
}
